package org.nterlearning.datamodel.catalog.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import org.nterlearning.datamodel.catalog.model.FlagReportStats;
import org.nterlearning.datamodel.catalog.model.FlagReportStatsModel;

import java.io.Serializable;

import java.sql.Types;

/**
 * The base model implementation for the FlagReportStats service. Represents a row in the &quot;CATALOG_FlagReportStats&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link org.nterlearning.datamodel.catalog.model.FlagReportStatsModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link FlagReportStatsImpl}.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see FlagReportStatsImpl
 * @see org.nterlearning.datamodel.catalog.model.FlagReportStats
 * @see org.nterlearning.datamodel.catalog.model.FlagReportStatsModel
 * @generated
 */
public class FlagReportStatsModelImpl extends BaseModelImpl<FlagReportStats>
    implements FlagReportStatsModel {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. All methods that expect a flag report stats model instance should use the {@link org.nterlearning.datamodel.catalog.model.FlagReportStats} interface instead.
     */
    public static final String TABLE_NAME = "CATALOG_FlagReportStats";
    public static final Object[][] TABLE_COLUMNS = {
            { "flagReportStatsId", Types.BIGINT },
            { "classNameId", Types.BIGINT },
            { "classPK", Types.BIGINT },
            { "totalEntries", Types.INTEGER },
            { "totalModerated", Types.INTEGER },
            { "totalApproved", Types.INTEGER }
        };
    public static final String TABLE_SQL_CREATE = "create table CATALOG_FlagReportStats (flagReportStatsId LONG not null primary key,classNameId LONG,classPK LONG,totalEntries INTEGER,totalModerated INTEGER,totalApproved INTEGER)";
    public static final String TABLE_SQL_DROP = "drop table CATALOG_FlagReportStats";
    public static final String ORDER_BY_JPQL = " ORDER BY flagReportStats.classNameId DESC, flagReportStats.classPK DESC";
    public static final String ORDER_BY_SQL = " ORDER BY CATALOG_FlagReportStats.classNameId DESC, CATALOG_FlagReportStats.classPK DESC";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.org.nterlearning.datamodel.catalog.model.FlagReportStats"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.org.nterlearning.datamodel.catalog.model.FlagReportStats"),
            true);
    public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.column.bitmask.enabled.org.nterlearning.datamodel.catalog.model.FlagReportStats"),
            true);
    public static long CLASSNAMEID_COLUMN_BITMASK = 1L;
    public static long CLASSPK_COLUMN_BITMASK = 2L;
    public static long FLAGREPORTSTATSID_COLUMN_BITMASK = 4L;
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.org.nterlearning.datamodel.catalog.model.FlagReportStats"));
    private static ClassLoader _classLoader = FlagReportStats.class.getClassLoader();
    private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
            FlagReportStats.class
        };
    private long _flagReportStatsId;
    private long _originalFlagReportStatsId;
    private boolean _setOriginalFlagReportStatsId;
    private long _classNameId;
    private long _originalClassNameId;
    private boolean _setOriginalClassNameId;
    private long _classPK;
    private long _originalClassPK;
    private boolean _setOriginalClassPK;
    private Integer _totalEntries;
    private Integer _totalModerated;
    private Integer _totalApproved;
    private transient ExpandoBridge _expandoBridge;
    private long _columnBitmask;
    private FlagReportStats _escapedModelProxy;

    public FlagReportStatsModelImpl() {
    }

    public long getPrimaryKey() {
        return _flagReportStatsId;
    }

    public void setPrimaryKey(long primaryKey) {
        setFlagReportStatsId(primaryKey);
    }

    public Serializable getPrimaryKeyObj() {
        return new Long(_flagReportStatsId);
    }

    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    public Class<?> getModelClass() {
        return FlagReportStats.class;
    }

    public String getModelClassName() {
        return FlagReportStats.class.getName();
    }

    public long getFlagReportStatsId() {
        return _flagReportStatsId;
    }

    public void setFlagReportStatsId(long flagReportStatsId) {
        _columnBitmask |= FLAGREPORTSTATSID_COLUMN_BITMASK;

        if (!_setOriginalFlagReportStatsId) {
            _setOriginalFlagReportStatsId = true;

            _originalFlagReportStatsId = _flagReportStatsId;
        }

        _flagReportStatsId = flagReportStatsId;
    }

    public long getOriginalFlagReportStatsId() {
        return _originalFlagReportStatsId;
    }

    public String getClassName() {
        if (getClassNameId() <= 0) {
            return StringPool.BLANK;
        }

        return PortalUtil.getClassName(getClassNameId());
    }

    public long getClassNameId() {
        return _classNameId;
    }

    public void setClassNameId(long classNameId) {
        _columnBitmask = -1L;

        if (!_setOriginalClassNameId) {
            _setOriginalClassNameId = true;

            _originalClassNameId = _classNameId;
        }

        _classNameId = classNameId;
    }

    public long getOriginalClassNameId() {
        return _originalClassNameId;
    }

    public long getClassPK() {
        return _classPK;
    }

    public void setClassPK(long classPK) {
        _columnBitmask = -1L;

        if (!_setOriginalClassPK) {
            _setOriginalClassPK = true;

            _originalClassPK = _classPK;
        }

        _classPK = classPK;
    }

    public long getOriginalClassPK() {
        return _originalClassPK;
    }

    public Integer getTotalEntries() {
        return _totalEntries;
    }

    public void setTotalEntries(Integer totalEntries) {
        _totalEntries = totalEntries;
    }

    public Integer getTotalModerated() {
        return _totalModerated;
    }

    public void setTotalModerated(Integer totalModerated) {
        _totalModerated = totalModerated;
    }

    public Integer getTotalApproved() {
        return _totalApproved;
    }

    public void setTotalApproved(Integer totalApproved) {
        _totalApproved = totalApproved;
    }

    public long getColumnBitmask() {
        return _columnBitmask;
    }

    @Override
    public FlagReportStats toEscapedModel() {
        if (_escapedModelProxy == null) {
            _escapedModelProxy = (FlagReportStats) ProxyUtil.newProxyInstance(_classLoader,
                    _escapedModelProxyInterfaces,
                    new AutoEscapeBeanHandler(this));
        }

        return _escapedModelProxy;
    }

    @Override
    public ExpandoBridge getExpandoBridge() {
        if (_expandoBridge == null) {
            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
                    FlagReportStats.class.getName(), getPrimaryKey());
        }

        return _expandoBridge;
    }

    @Override
    public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
        getExpandoBridge().setAttributes(serviceContext);
    }

    @Override
    public Object clone() {
        FlagReportStatsImpl flagReportStatsImpl = new FlagReportStatsImpl();

        flagReportStatsImpl.setFlagReportStatsId(getFlagReportStatsId());
        flagReportStatsImpl.setClassNameId(getClassNameId());
        flagReportStatsImpl.setClassPK(getClassPK());
        flagReportStatsImpl.setTotalEntries(getTotalEntries());
        flagReportStatsImpl.setTotalModerated(getTotalModerated());
        flagReportStatsImpl.setTotalApproved(getTotalApproved());

        flagReportStatsImpl.resetOriginalValues();

        return flagReportStatsImpl;
    }

    public int compareTo(FlagReportStats flagReportStats) {
        int value = 0;

        if (getClassNameId() < flagReportStats.getClassNameId()) {
            value = -1;
        } else if (getClassNameId() > flagReportStats.getClassNameId()) {
            value = 1;
        } else {
            value = 0;
        }

        value = value * -1;

        if (value != 0) {
            return value;
        }

        if (getClassPK() < flagReportStats.getClassPK()) {
            value = -1;
        } else if (getClassPK() > flagReportStats.getClassPK()) {
            value = 1;
        } else {
            value = 0;
        }

        value = value * -1;

        if (value != 0) {
            return value;
        }

        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }

        FlagReportStats flagReportStats = null;

        try {
            flagReportStats = (FlagReportStats) obj;
        } catch (ClassCastException cce) {
            return false;
        }

        long primaryKey = flagReportStats.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public void resetOriginalValues() {
        FlagReportStatsModelImpl flagReportStatsModelImpl = this;

        flagReportStatsModelImpl._originalFlagReportStatsId = flagReportStatsModelImpl._flagReportStatsId;

        flagReportStatsModelImpl._setOriginalFlagReportStatsId = false;

        flagReportStatsModelImpl._originalClassNameId = flagReportStatsModelImpl._classNameId;

        flagReportStatsModelImpl._setOriginalClassNameId = false;

        flagReportStatsModelImpl._originalClassPK = flagReportStatsModelImpl._classPK;

        flagReportStatsModelImpl._setOriginalClassPK = false;

        flagReportStatsModelImpl._columnBitmask = 0;
    }

    @Override
    public CacheModel<FlagReportStats> toCacheModel() {
        FlagReportStatsCacheModel flagReportStatsCacheModel = new FlagReportStatsCacheModel();

        flagReportStatsCacheModel.flagReportStatsId = getFlagReportStatsId();

        flagReportStatsCacheModel.classNameId = getClassNameId();

        flagReportStatsCacheModel.classPK = getClassPK();

        flagReportStatsCacheModel.totalEntries = getTotalEntries();

        flagReportStatsCacheModel.totalModerated = getTotalModerated();

        flagReportStatsCacheModel.totalApproved = getTotalApproved();

        return flagReportStatsCacheModel;
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(13);

        sb.append("{flagReportStatsId=");
        sb.append(getFlagReportStatsId());
        sb.append(", classNameId=");
        sb.append(getClassNameId());
        sb.append(", classPK=");
        sb.append(getClassPK());
        sb.append(", totalEntries=");
        sb.append(getTotalEntries());
        sb.append(", totalModerated=");
        sb.append(getTotalModerated());
        sb.append(", totalApproved=");
        sb.append(getTotalApproved());
        sb.append("}");

        return sb.toString();
    }

    public String toXmlString() {
        StringBundler sb = new StringBundler(22);

        sb.append("<model><model-name>");
        sb.append("org.nterlearning.datamodel.catalog.model.FlagReportStats");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>flagReportStatsId</column-name><column-value><![CDATA[");
        sb.append(getFlagReportStatsId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
        sb.append(getClassNameId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>classPK</column-name><column-value><![CDATA[");
        sb.append(getClassPK());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>totalEntries</column-name><column-value><![CDATA[");
        sb.append(getTotalEntries());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>totalModerated</column-name><column-value><![CDATA[");
        sb.append(getTotalModerated());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>totalApproved</column-name><column-value><![CDATA[");
        sb.append(getTotalApproved());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
